<?php

namespace App\Kuafu\WaiMai\Enum;

use App\Kuafu\Base\Enum\BaseCodeEnum;

class WaiMaiCacheEnum extends BaseCodeEnum
{
    private const ELM_TOKEN    = 'elm-token';
    private const SHOP_MAPPING = 'shop-mapping';
    private const THIRD_SHOP_MAPPING = 'third-shop-mapping';
    private const MQTT_WAI_MAI_PUSH = 'mqtt-wai-mai-push';
    private const ELM_SINGLE_REFRESH = 'elm-single-refresh';
    private const MT_API_CURL_NUM = 'mt-api-curl_num';
    private const DY_API_CURL_NUM = 'dy-api-curl_num';
    private const SHOP_WAIMAI_PRODUCTS = 'shop-waimai-products';
    private const MT_SECURE_CARD = 'mt_secure_card';
    private const FUNC_LOCK = 'func-lock';

    /**
     * 饿了么token
     * @return string
     */
    public static function getElmToken(string $appId): string
    {
        return sprintf(self::ELM_TOKEN . "%s", $appId);
    }

    /**
     * 店铺的外卖、团购映射
     * @param int $shopId
     * @param int $sourceType
     * @return string
     */
    public static function getShopMapping(int $shopId, int $sourceType): string
    {
        return sprintf(self::SHOP_MAPPING . ":%d:%d", $shopId, $sourceType);
    }

    /**
     * 外部店铺代码映射
     * @param string $thirdShopId
     * @param int $sourceType
     * @return string
     */
    public static function getThirdShopMapping(string $thirdShopId, int $sourceType): string
    {
        return sprintf(self::THIRD_SHOP_MAPPING . ':%s:%d', $thirdShopId, $sourceType);
    }

    /**
     * mqtt外卖推送去重
     * @param int $orderId
     * @param int $operateType
     * @param string $dataMd5
     * @return string
     */
    public static function getMqttWaiMaiPush(int $orderId, int $operateType, string $dataMd5): string
    {
        return sprintf(self::MQTT_WAI_MAI_PUSH.':%d:%d:%s', $orderId, $operateType, $dataMd5);
    }

    /**
     * 饿了么 - 单进程获取accessToken锁
     * @return string
     */
    public static function getElmSingleRefresh(): string
    {
        return self::ELM_SINGLE_REFRESH;
    }

    /**
     * 美团调用接口次数
     * @return string
     */
    public static function getMtApiCurlNum(): string
    {
        return self::MT_API_CURL_NUM;
    }

    /**
     * 店铺的外卖菜品列表
     * @param int $shopId
     * @param int $sourceType
     * @return string
     */
    public static function getShopWaiMaiProducts(int $shopId, int $sourceType)
    {
        return sprintf(self::SHOP_WAIMAI_PRODUCTS.':%d:%d', $shopId, $sourceType);
    }

    /**
     * 美团安心卡
     * @param int $shopId
     * @return string
     */
    public static function getMtSecureCard(int $shopId)
    {
        return sprintf(self::MT_SECURE_CARD . ":%d", $shopId);
    }

    /**
     * 外卖方法锁
     * @param string $orderId
     * @param string $funcName
     * @return string
     */
    public static function getFuncLock(string $orderId, string $funcName): string
    {
        return sprintf(self::FUNC_LOCK.'%s:%s', $funcName, $orderId);
    }

    /**
     * 抖音调用接口次数
     * @return string
     */
    public static function getDyApiCurlNum(): string
    {
        return self::DY_API_CURL_NUM;
    }
}
